<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button th:onclick="send()" value="发送"></button>
</body>
<script type="text/javascript">
    var websocket = null;

    //判断当前浏览器是否支持WebSocket
    if('WebSocket' in window){
        websocket = new WebSocket("ws://localhost:9001/cfgjht/websocket/1");
    }
    else{
        alert('Not support websocket')
    }
    function send() {
        var message = "go"
        websocket.send(message);
    }

</script>
</html>